home *** CD-ROM | disk | FTP | other *** search
- function reset()
- {
- var colloop = 1;
- var rowloop = 1;
- var count = 0;
- rowloop = 1;
- while(highestturn + 1 >= rowloop)
- {
- colloop = 1;
- while(highestlevel + 2 >= colloop)
- {
- with(eval("_root.peg" + rowloop + colloop))
- {
- if(currentlevel + 2 >= colloop)
- {
- gotoAndStop("lblColour0");
- }
- else
- {
- gotoAndStop("lblColour255");
- }
- }
- colloop++;
- }
- rowloop++;
- }
- count = 1;
- while(highestturn >= count)
- {
- eval("_root.colorclue" + count).gotoAndStop("lbl255");
- eval("_root.placeclue" + count).gotoAndStop("lbl255");
- count++;
- }
- _root.level.gotoAndStop("lbl" + currentlevel);
- _root.action.gotoAndStop("lblGo");
- currentturn = 1;
- currentpeg = 1;
- count = 0;
- while(highestlevel + 2 - 1 >= count)
- {
- userarray[count] = 0;
- answerarray[count] = 0;
- count++;
- }
- initialiseanswerarray();
- gameover = false;
- }
- function initialiseanswerarray()
- {
- var count = 0;
- count = 0;
- while(currentlevel + 2 - 1 >= count)
- {
- answerarray[count] = Math.round(Math.random() * 6) + 1;
- count++;
- }
- }
- function setpeg(PegNumber)
- {
- if(gameover == false && currentlevel + 2 >= currentpeg)
- {
- eval("_root.peg" + currentturn + currentpeg).gotoAndStop("lblColour" + PegNumber);
- userarray[currentpeg - 1] = PegNumber;
- currentpeg++;
- }
- }
- function back()
- {
- if(gameover == false && 1 < currentpeg)
- {
- currentpeg--;
- eval("_root.peg" + currentturn + currentpeg).gotoAndStop("lblColour0");
- }
- }
- function levelup()
- {
- if(currentlevel < highestlevel)
- {
- currentlevel++;
- reset();
- }
- }
- function leveldn()
- {
- if(lowestlevel < currentlevel)
- {
- currentlevel--;
- reset();
- }
- }
- function actionhandler()
- {
- var count = 0;
- var winflag = false;
- if(gameover == false)
- {
- if(currentlevel + 2 < currentpeg)
- {
- showclues();
- winflag = true;
- count = 0;
- while(currentlevel + 2 - 1 >= count)
- {
- if(answerarray[count] != userarray[count])
- {
- winflag = false;
- }
- count++;
- }
- if(currentturn >= highestturn || winflag == true)
- {
- count = 0;
- while(currentlevel + 2 - 1 >= count)
- {
- eval("_root.peg" + (highestturn + 1) + (count + 1)).gotoAndStop("lblColour" + answerarray[count]);
- count++;
- }
- _root.action.gotoAndStop("lblNew");
- gameover = true;
- if(winflag == true)
- {
- _root.sounds.gotoAndPlay("lblWinner");
- }
- else
- {
- _root.sounds.gotoAndPlay("lblLoser");
- }
- }
- currentpeg = 1;
- currentturn++;
- }
- }
- else
- {
- reset();
- }
- }
- function showclues()
- {
- var count = 0;
- var count2 = 0;
- var colorclue = 0;
- var placeclue = 0;
- var tempuserarray = new Array(highestlevel + 2);
- var tempanswerarray = new Array(highestlevel + 2);
- count = 0;
- while(currentlevel + 2 - 1 >= count)
- {
- tempuserarray[count] = userarray[count];
- tempanswerarray[count] = answerarray[count];
- count++;
- }
- count = 0;
- while(currentlevel + 2 - 1 >= count)
- {
- count2 = 0;
- while(currentlevel + 2 - 1 >= count2)
- {
- if(tempuserarray[count] == tempanswerarray[count2] && count == count2 && tempuserarray[count] != 0 && tempanswerarray[count2] != 0)
- {
- colorclue++;
- placeclue++;
- tempuserarray[count] = 0;
- tempanswerarray[count2] = 0;
- }
- count2++;
- }
- count++;
- }
- count = 0;
- while(currentlevel + 2 - 1 >= count)
- {
- count2 = 0;
- while(currentlevel + 2 - 1 >= count2)
- {
- if(tempuserarray[count] == tempanswerarray[count2] && count != count2 && tempuserarray[count] != 0 && tempanswerarray[count2] != 0)
- {
- colorclue++;
- tempuserarray[count] = 0;
- tempanswerarray[count2] = 0;
- }
- count2++;
- }
- count++;
- }
- eval("_root.colorclue" + currentturn).gotoAndStop("lbl" + colorclue);
- eval("_root.placeclue" + currentturn).gotoAndStop("lbl" + placeclue);
- }
- var lowestlevel = 1;
- var highestlevel = 7;
- var currentlevel = lowestlevel + 1;
- var highestturn = 10;
- var currentturn = 1;
- var currentpeg = 1;
- var userarray = new Array(highestlevel + 2);
- var answerarray = new Array(highestlevel + 2);
- var gameover = false;
- var fullscreengame = false;
- fscommand("fullscreen","true");
- fullscreengame = true;
- reset();
-